function chkTaoUser(obj) {
	if (obj.value=='输入您的淘宝帐号看下能省多少钱？' || obj.value=='') {
		obj.value = '';
		obj.focus();
		return false;
	}
	return true;
}
var saveprice = 0;
var tits = '';
var uids = '';
var price = '';
function getTaobaoke(uid) {
	var ajax0 = new Ajax('inc/taobao.ajax.php', 0, 'act=getBuy&uid='+uid+'&p=1', bacal);
	ajax0.get();
	function bacal(rexm) {
		if (rexm=='') return false;
		if(rexm.indexOf("failed to open stream")>0)setTimeout("getTaobaoke("+uid+")", 1000);
		else{
		rexm=rexm.replace("TB.rateList = ","").replace("<br/>","");
		var buy = eval('(' + rexm + ')');
		var buypage = buy.rateList.paginator;
		var buylist = buy.rateList.rateListDetail;
		var tmp = '';
		var totalmoney = 0;
		var starttime = '';
		if (buylist[0].rateDate!=null) starttime = buylist[0].rateDate;
		var stoptime = '';
		if (buylist[buypage.length-1].rateDate!=null) stoptime = buylist[buypage.length-1].rateDate;
		if (parseInt(buypage.length)>0) {
			for (var i=0; i<parseInt(buypage.length); i++) {
				totalmoney += parseFloat(buylist[i].auctionPrice);
				if(buylist[i].displayRatePic=="order_mall.png")
				{tmp += '<table width="95%" border="0" cellpadding="0" cellspacing="0"><tr><td><span class="user_name"><a href="/list.php?q='+encodeURI(buylist[i].auctionTitle)+'" target="_blank">'+buylist[i].auctionTitle+'</a><br /><em>'+buylist[i].rateDate+'</em></span></td><td><div align="center"><span class="host"><a href="/shop.php?nick='+encodeURI(buylist[i].displayUserNick)+'" target="_blank">'+buylist[i].displayUserNick+'</a><br /><img src="http://a.tbcdn.cn/sys/common/icon/trade/'+buylist[i].displayRatePic+'" /></span></div></td> <td align="center"><div><span class="prise">￥'+buylist[i].auctionPrice+'</span></div></td><td><div align="center"><span class="recome" id="back_'+i+'">获取中...</span></div>></td></tr></table>';}
				else
				{tmp += '<table width="95%" border="0" cellpadding="0" cellspacing="0"><tr><td><span class="user_name"><a href="/list.php?q='+encodeURI(buylist[i].auctionTitle)+'" target="_blank">'+buylist[i].auctionTitle+'</a><br /><em>'+buylist[i].rateDate+'</em></span></td><td><div align="center"><span class="host"><a href="/shop.php?nick='+encodeURI(buylist[i].displayUserNick)+'" target="_blank">'+buylist[i].displayUserNick+'</a><br /><img src="http://pics.taobaocdn.com/newrank/'+buylist[i].displayRatePic+'" /></span></div></td><td><span class="prise">￥'+buylist[i].auctionPrice+'</span></td><td><span class="recome" id="back_'+i+'">获取中...</span></div></td></tr></table>';}
				tits += (buylist[i].auctionTitle)+"{}";
				uids += (buylist[i].displayUserNick)+"{}";
				price += buylist[i].auctionPrice+"{}";
			}
		}
		totalmoney = totalmoney.toFixed(2);
		document.getElementById('buylist').innerHTML = tmp;
		document.getElementById('totPrice').innerHTML = "￥"+totalmoney;
		document.getElementById('totPrice1').innerHTML = "￥"+totalmoney;
		document.getElementById('starttime').innerHTML = starttime.split(' ')[0];
		document.getElementById('stoptime').innerHTML = stoptime.split(' ')[0];
		setTimeout("getBuyer(0)", 1000);
	}
	}
}
function getBuyer(j) {
	var tit = tits.split("{}");
	var uid = uids.split("{}");
	var pri = price.split("{}");
	if (tit.length-1<=j) return false;
	var ajax0 = new Ajax('inc/taobao.ajax.php', 0, 'act=getbuyer&k='+encodeURI(tit[j])+'&n='+encodeURI(uid[j])+'&p='+pri[j], bacal);
	ajax0.get();
	function bacal(rexm) {
		document.getElementById('back_'+j).className = 'recome red';
		if (parseFloat(rexm)>0) {
			document.getElementById('back_'+j).innerHTML = '￥'+rexm;
			//document.getElementById('item_url_'+j).href = tmp[0];
			//document.getElementById('shop_url_'+j).href = tmp[1];
			saveprice = saveprice+parseFloat(rexm);
			saveprice = Math.round(saveprice*100)/100;
			if (document.getElementById('backPrice')!=null) document.getElementById('backPrice').innerHTML = "￥"+saveprice;
			if (document.getElementById('backPrice1')!=null) document.getElementById('backPrice1').innerHTML = "￥"+saveprice;
		} else {
			document.getElementById('back_'+j).innerHTML = '￥0';
		}
		j++;
		setTimeout("getBuyer("+j+")", 100);
	}
}
function setCookie(cookieName,cookieValue,t){
	var date = new Date();
	date.setTime(date.getTime() + 60*60*1000);
	var tmp = "expires=" + date.toGMTString() + ";"
	if (t!=null) tmp = '';
	document.cookie = cookieName + "=" + cookieValue + ";" + tmp + "path=/;domain=.egouo.net";
}

